package com.example.userservice.controller;


import com.example.userservice.clients.OrderClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * ClassName: UserController
 * PackageName: com.example.orderservice.controller
 * Describe:
 *
 * @author: Cheng Wenying
 * @Create: 2023/10/24
 * @version:
 */
@RestController
@RequestMapping("user")
public class UserController {

    //    @Autowired
//    RestTemplate restTemplate;
    @Autowired
    OrderClient orderClient;


    @GetMapping("/getUserData")
    public String getUserData() {
        return "返回的用户数据：姓名：张三，年龄：18";
    }

    @GetMapping("/add")
    public String addOrder() {
//        String forObject = restTemplate.getForObject("http://order-service/order/add", String.class);
        // 用fegin远程调用
        String add = orderClient.add();
//        return "调用成功:" + forObject;
        return add;
    }

}
